package com.xu.chuang.show.ui;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.MultiAutoCompleteTextView;
import android.widget.TextView;

import com.xu.chuang.show.R;
import com.xu.chuang.show.bean.Content;
import com.xu.chuang.show.bean.ShowUser;
import com.xu.chuang.show.network.SyncRequest;
import com.xu.chuang.show.service.impl.MainBizReqImpl;
import com.xu.chuang.show.service.inte.MainBizReqService;

public class MarkerViewActivity extends AppCompatActivity {

    public static final String ARG_PARAMContent = "content";

    private Content content;

    private TextView locationTextView;

    private MultiAutoCompleteTextView contextMutiTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_marker_view);

        SyncRequest.syncReq();

        SyncRequest.syncReq();
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        content = (Content) bundle.get(ARG_PARAMContent);

        contextMutiTextView = (MultiAutoCompleteTextView)
                findViewById(R.id.et_view_context);
        locationTextView = (TextView) findViewById(R.id.et_view_location);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(R.string.content_detail);
        setSupportActionBar(toolbar);

        toolbar.setNavigationIcon(R.drawable.return_left_arrow);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        requestSetView();
    }

    private void requestSetView(){
        contextMutiTextView.setText(content.getContext());
        MainBizReqService mainBizReqService = new MainBizReqImpl();
        ShowUser showUser = mainBizReqService.getOtherUser(content.getContentId());
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(showUser.getNickName())
                .append(" ")
                .append(content.getUpTime())
                .append(R.string.upload);
        locationTextView.setText(stringBuilder.toString());
    }
}
